import matplotlib.pyplot as plt
import numpy as np
from test0 import create_coordinate_system

# 支持中文
plt.rcParams['font.family'] = ['sans-serif']
plt.rcParams['font.sans-serif'] = ['SimHei']

# 创建一个坐标系
fig, ax = create_coordinate_system(x_range=(-10, 10), y_range=(-10, 10), figsize=(8, 8))

# 添加一个二次函数的图像
x = np.linspace(-1, 5, 100)
y = (x-2)**2 - 2 

# x 和 y 互换
x1 = y
y1 = x

# 绘制二次函数的图像
ax.plot(x, y, 'r-', linewidth=2, label='y = f(x)', color='black')
ax.plot(x1, y1, 'r-', linewidth=2, label='关于y=x对称的函数', color='red')

ax.legend()
plt.show()
